home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ubisoft Digital Press Ki….S.A./North America (USA)
/
Ubisoft Digital Press Kit 99 U.S.A.-North America (USA).bin
/
Dcr
/
language2.cst
/
00036_Script_Scroll Text Beh contact
< prev
next >
Wrap
Text File
|
1999-05-03
|
3KB
|
95 lines
-- Scroll Text Behavior
---------------------------------------------------------------
-- This behavior the text in response to messages from the
-- arrow buttons, track, or indicator.
--
-- You attach this behavior to a text sprite.
--
-- 10/22/97 David Benman
---------------------------------------------------------------
-- pTextSprite - the behavior's sprite.
-- pTextMember - member reference for the text member in the sprite.
-- pTextLowerLimit - lower limit for the text scrolling.
-- pTextRange - entire range the text scrolls.
-- pLineSize - the amount the text scrolls when the
-- user clicks a button once. Usually the line height.
property pTextSpritec, pTextMemberc, pTextLowerLImitc, pTextRangec, pLineSizec, pPageSizec, pTextOrigin
-- This handler initializes several properties, sets the limits
-- for the text scrolling, and scrolls the text to its beginning
-- position.
on beginSprite me
set pLineSizec to 13
set totalLines to 15
set pPageSizec to totalLines * pLineSizec
set pTextOrigin to 255
set pTextSpritec to the spriteNum of me
set pTextMemberc to the member of sprite pTextSpritec
set lastOffset to integer(0.5 * totalLines) * plineSizec
set textUpperLimit to the height of member pTextMemberc - lastOffset
set pTextLowerLimitc to 0
set pTextRangec to textUpperLimit - pTextLowerLimitc
set the locV of sprite pTextSpritec to pTextOrigin
end
-- This handler scrolls the text in response to messages from the
-- arrow buttons, track, or indicator.
-- direction - either a symbol indicating the direction of scrolling
-- or a proportion to indicate a specific position.
-- scrollType - contains the symbol #page when scrolling should
-- be by page.
on scrollTextc me, directionc, scrollType
-- Sets the scrollAmount either a line or page depending on
-- the value for scrollType.
case TRUE of
(voidP(scrollType)):
set scrollAmount to pLineSizec
(scrollType = #page):
set scrollAmount to pPageSizec
end case
-- Determines the next scroll position for the text. Sets the
-- next position to plus or minus one line, one page, or a specific
-- position depending on the value of direction.
if symbolP(directionc) then
case directionc of
#down: set scrollDirectionc to 1
#up: set scrollDirectionc to -1
end case
set scrollVector to scrollAmount * scrollDirectionc
set currentPosition to pTextOrigin -the locV of sprite pTextSpritec
set nextPosition to currentPosition + scrollVector
if nextPosition > pTextLowerLimitc + pTextRangec then
set nextPosition to pTextLowerLimitc + pTextRangec
else
if nextPosition < pTextLowerLimitc then
set nextPosition to pTextLowerLimitc
end if
end if
else
set nextPosition to directionc * pTextRangec
end if
-- Sets the text to the next position.
set the locV of sprite pTextSpritec to pTextOrigin - nextPosition
-- Sends a message to position the indicator to match the text.
sendAllSprites(#positionIndicatorc, float(nextPosition)/pTextRangec)
end